﻿//arcgis服务
function TileArcgisService(layerInfo) {
    var TileArcgisService = new Object;
    TileArcgisService.id = layerInfo.hasOwnProperty("GUID") ? layerInfo.GUID : "";
    TileArcgisService.url = layerInfo.hasOwnProperty("URL") ? layerInfo.URL : "";
    TileArcgisService.name = layerInfo.hasOwnProperty("NAME") ? layerInfo.NAME : "";
    TileArcgisService.layerid = layerInfo.hasOwnProperty("PARAMETERS") ? layerInfo.PARAMETERS : "";
    TileArcgisService.servertype = layerInfo.hasOwnProperty("SERVERTYPE") ? layerInfo.SERVERTYPE : "";
    TileArcgisService.showLayer = (layerInfo.hasOwnProperty("PARAMETERS") && layerInfo.PARAMETERS != "") ? layerInfo.PARAMETERS : layerInfo.ID;
    TileArcgisService.CreateLayer = function () {
        var id = this.id;
        var tileMatrixLabels = [];
        for (var i = 0 ; i < 24 ; i++) {
            tileMatrixLabels.push(i + "");
        }
        var url = this.url;
        var name = this.name;
        var servertype = this.servertype;
        var showLayer = this.showLayer == "" ? "" : "show:" + this.showLayer;
        var proxyUrl = "";
        var layers = viewer.imageryLayers;
        var layerindex = layers._layers.length;

        var thisLayer = layers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider({
            url : url + '/WMTS',
            layer: this.layerid,
            style : 'default',
            format : 'image/jpeg',
            tileMatrixSetID : 'default028mm',
            tileMatrixLabels: tileMatrixLabels,
            maximumLevel: 23,
            credit: new Cesium.Credit(''),
            proxy: new Cesium.DefaultProxy('/proxy/')
        }));
        checkLayerTransparent(thisLayer, id);
        return thisLayer;
    }
    return TileArcgisService;
}